const state = {
  openTab: [],
  activeIndex: "",
};
const mutations = {
  add_tabs(state, data) {
    if (data.route === "/home") {
      return;
    } else {
      state.openTab.push(data);
    }
  },
  delete_tabs(state, route) {
    let index = 0;
    for (let gohh of state.openTab) {
      if (gohh.route === route) {
        break;
      }
      index++;
    }
    state.openTab.splice(index, 1);
  },
  set_active_index(state, index) {
    state.activeIndex = index;
  },
  clearTags(state) {
    state.openTab = [];
    state.activeIndex = "";
  },
};

export default {
  namespaced: true,
  state,
  mutations,
};
